package cn.base.web.support.interceptor;

import cn.base.web.authc.AccessControl;
import cn.rengy.auth.Authentication;
import cn.rengy.lang.ResultEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;

/**
 * 允许所有访问，不做权限控制
 */
@Component
@ConditionalOnProperty(name = "enable.cn.base.web.support.interceptor.AllowAllAccessControl", havingValue = "true",matchIfMissing=false)
@Slf4j
public class AllowAllAccessControl implements AccessControl {
    @Override
    public ResultEntity<HttpStatus,Authentication> isAccessAllowed(Object _request, Object _response) {
        log.info("allow all request");
        return ResultEntity.ok(HttpStatus.OK,null);
    }
}
